package io.file;

import org.apache.commons.net.ftp.FTPClient;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class FTPCreatePath {
    public static void main(String[] args) {
        FTPClient client=new FTPClient();
        try {
            client.connect("119.29.194.44",21);
            client.login("administrator","5582591hjf..");
            client.enterLocalPassiveMode();
            client.changeWorkingDirectory("C:\\GraduationProject\\cat_kjw\\cat_picture\\webapps\\picture\\root");
            client.makeDirectory("\\a");
            client.changeWorkingDirectory("a");
            System.out.println("args = [" + client.printWorkingDirectory() + "]");
            client.makeDirectory("c");
            //client.getReply()//这行代码有毒,会阻塞
            File file = new File("E:\\Project\\hi.txt");
            client.changeWorkingDirectory("c");
            System.out.println("args = [" + client.printWorkingDirectory() + "]");
            FileInputStream stream=new FileInputStream(file);
            client.storeFile("kjwsayhi",stream);
            stream.close();
            //client.logout();此方法调用后不能再调用quit()
            System.out.println("args = [" + client.isConnected() + "]");
            int result=client.quit();
            System.out.println("args = [" + result + "]");



        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
